package com.zx.task.manager.dao;

import com.zx.task.manager.model.Tasks;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface TasksMapper {
    int deleteByPrimaryKey(@Param("id") String id);

    int insert(Tasks row);

    int insertSelective(Tasks row);

    Tasks selectByPrimaryKey(@Param("id") String id);

    int updateByPrimaryKeySelective(Tasks row);

    int updateByPrimaryKey(Tasks row);

    /**
     * 根据父任务ID查询子任务列表
     *
     * @param parentId 父任务ID
     * @return {@link List<Tasks>}
     * @author zhou  xun
     * @since 2025-10-22
     */
    List<Tasks> selectTasksByParentId(@Param("parentId") String parentId);

    /**
     * 根据任务类型ID查询任务列表
     *
     * @param taskTypeId 任务类型ID
     * @return {@link List<Tasks>}
     * @author zhou  xun
     * @since 2025-10-14
     */
    List<Tasks> selectTaskListByTaskTypeId(@Param("taskTypeId") String taskTypeId);

    /**
     * 批量根据任务ID查询任务列表
     *
     * @param taskIds 任务ID列表
     * @return {@link List<Tasks>}
     * @author zhou  xun
     * @since 2025-10-22
     */
    List<Tasks> selectBatchTaskByIds(@Param("taskIds") List<String> taskIds);

    Long getTasksListCount(@Param("taskNo") String taskNo,
                           @Param("title") String title,
                           @Param("taskTypeId") String taskTypeId,
                           @Param("priority") Integer priority,
                           @Param("status") Integer status,
                           @Param("createTimeStart") LocalDateTime createTimeStart,
                           @Param("createTimeEnd") LocalDateTime createTimeEnd);

    List<Tasks> getTasksListByPage(@Param("taskNo") String taskNo,
                                   @Param("title") String title,
                                   @Param("taskTypeId") String taskTypeId,
                                   @Param("priority") Integer priority,
                                   @Param("status") Integer status,
                                   @Param("createTimeStart") LocalDateTime createTimeStart,
                                   @Param("createTimeEnd") LocalDateTime createTimeEnd,
                                   @Param("pageNum") Long pageNum,
                                   @Param("pageSize") Long pageSize);
}